package sample4.provider.ddl;

import java.util.ArrayList;
import java.util.List;

import android.database.sqlite.SQLiteDatabase;

abstract class AbsDdlBuilder {
    private String mName;
    private List<String> mColumnNames;

    AbsDdlBuilder(String name) {
        this.mName = name;
        this.mColumnNames = new ArrayList<String>();
    }

    public String getName() {
        return mName;
    }

    protected void addColumn(String column) {
        mColumnNames.add(column);
    }

    protected List<String> getColumn() {
        return mColumnNames;
    }

    public final void create(SQLiteDatabase db) {
        db.execSQL(toCreateSql());
    }

    public final void drop(SQLiteDatabase db) {
        db.execSQL(toDropSql());
    }

    @Override
    public final String toString() {
        return "----CREATE---\n" + toCreateSql();
    }

    abstract String toCreateSql();

    abstract String toDropSql();
}
